using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using Entites;
using DAL;
namespace BUS
{
   public class DuLichBUS
    {
        public static void Insert(DuLich dl)
        {
            DuLichDAL dlDAL = new DuLichDAL();
            dlDAL.Insert(dl);
        }
        public static void Update(DuLich dl)
        {
            DuLichDAL dlDAL = new DuLichDAL();
            dlDAL.Update(dl);
        }
        public static void Delete(int iD)
        {
            DuLichDAL dlDAL = new DuLichDAL();
            dlDAL.Delete(iD);
        }
        public static tbDuLichCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            DuLichDAL dlDAL = new DuLichDAL();
            return dlDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbDuLichCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            DuLichDAL dlDAL = new DuLichDAL();
            return dlDAL.Get(cri.Criter, 0, 0, tbDuLichColumns.MaDuLich.ToString(), OrderDirection.ASC.ToString(), out total);
        }
       public static DuLich GetByID(int iD)
       {
           int total = 0;
           Criteria cri = new Criteria();
           cri.add(Condition.AND, tbDuLichColumns.MaDuLich.ToString(), Condition.EQUAL, iD);
           DuLichDAL dlDAL = new DuLichDAL();
           tbDuLichCollection dulichcollection = dlDAL.Get(cri.Criter,
                 0, 0, tbDonHangColumns.MaDH.ToString(), OrderDirection.ASC.ToString(), out total);
           if (dulichcollection.Count > 0)
               return dulichcollection[0];
           return null;
       }
      
        public static tbDuLichCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            DuLichDAL dlDAL = new DuLichDAL();
            return dlDAL.Get(cri.Criter, 1, number,
             tbDuLichColumns.MaDuLich.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbDuLichCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            DuLichDAL dlDAL = new DuLichDAL();
            return dlDAL.Get(cri.Criter, 1, number,
               tbDuLichColumns.MaDuLich.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
    

}
